package com.misolab.game.sbh.data.db.table;

import android.database.sqlite.SQLiteDatabase;

import com.misolab.game.sbh.data.db.DBConstant;
import com.misolab.game.sbh.util.log.Logger;

public class ContentTable implements ITable, DBConstant {

	final static String ClassName = ContentTable.class.getSimpleName();

	static void logFunc(String name) {
		Logger.i(ClassName + "::" + name + "()");
	}

	public static final String SQL_CREATETABLE = String.format("create table %s (%s integer primary key, %s text not null, %s integer not null, %s integer default 0)", 
			DB_TABLE_NAME, DB_COLUMN_CONTENT_ID, DB_COLUMN_CONTENT_NAME, DB_COLUMN_LEVEL_NAME, DB_COLUMN_COUNT_NAME);

	@Override
	public void create(SQLiteDatabase db) {
		logFunc("create");
		
		db.execSQL(SQL_CREATETABLE);		
	}

	@Override
	public void upgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		logFunc("upgrade");

		db.execSQL("DROP TABLE IF EXISTS " + DB_TABLE_NAME);
		create(db);
	}

	@Override
	public void upgradeTo(SQLiteDatabase db, int version) {
		logFunc("upgradeTo");

	}

}
